import { request } from '../utils/request'
import type { User, ApiResponse } from '../types'

// 微信登录
export const loginApi = (data: { 
  code?: string
  nickname?: string
  avatar_url?: string 
}) => {
  return request.post<ApiResponse<{ user: User; token: string }>>('/auth/wechat/login', data)
}

// 获取用户信息
export const getProfileApi = () => {
  return request.get<ApiResponse<{ user: User; can_generate: boolean }>>('/auth/profile')
}

// 更新用户信息
export const updateProfileApi = (data: Partial<User>) => {
  return request.put<ApiResponse<{ user: User }>>('/auth/profile', data)
}

// 登出
export const logoutApi = () => {
  return request.post<ApiResponse>('/auth/logout')
}